package com.ecr.hub.front.validator;

import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;

public class PasswordConfirmValidator extends AbstractGenericValidator {

	@Override
	protected boolean executeValidator(FacesContext arg0, UIComponent arg1,
			Object arg2) throws Exception {

		String confirmPassword;
		UIComponent Usercomponent = (UIComponent) arg0
				.getViewRoot()
				.findComponent(
						arg1.getAttributes().get("compareTo").toString().trim());
		confirmPassword = ((UIInput) Usercomponent).getSubmittedValue()
				.toString();

		return (confirmPassword.equals(arg2));
	}

	@Override
	protected String[] getAttributsList() {
		return null;
	}

	@Override
	protected String getMessageKey() {
		return "validator.password";
	}

	@Override
	protected Severity getSeverityLevel() {
		return FacesMessage.SEVERITY_ERROR;
	}
}